package com.suitsoft.bdms.commos;

import java.util.TimerTask;

import javax.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.suitsoft.bdms.service.imp.ImpManager;

/**
 * 定时同步
 *@author Suine
 */
public class SyncUserThread extends TimerTask{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	String viewName;

	public SyncUserThread(String viewName) {
		this.viewName = viewName;
	}
	@Override
	public void run() {
		WebApplicationContext wac = null;
		ServletContext application = AppConfig.getInstance().getApplication();
		wac = WebApplicationContextUtils.getWebApplicationContext(application);
		ImpManager impManager = (ImpManager) wac.getBean("impManager");
		logger.info("准备执行==" + viewName);
		impManager.syncUser(viewName);
//		impManager.testTimer(viewName);
		logger.info("执行完==" + viewName);
	}
}

